import java.util.Scanner;
public class Main {

    public class StringFormat {
        public String formatString(String A, int n, char[] arg, int m) {
            char[] ch = A.toCharArray();

            StringBuilder s = new StringBuilder();
            int j = 0;
            for(int i = 0;i < n;i++){
                if(ch[i] != '%') s.append(ch[i]);
                else
                {
                    if((i + 1 < n) && j < m)
                    {
                        s.append(arg[j++]);
                        i++;
                    }
                    else
                    {
                        s.append(ch[i]);
                    }
                }
            }

            while(j < m) s.append(arg[j++]);

            return s.toString();
        }
    }

    /**
     * 统计神奇数
     * @param args
     */
    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt(),b = in.nextInt();

        int cnt = 0;
        for(int i = a;i <= b;i++){
            if(i < 10) continue;
            if(check_num1(i)) cnt++;
        }

        System.out.println(cnt);
    }

    static private boolean check_num(int num) {

        char[] s = Integer.toString(num).toCharArray();
         int len = s.length;
         for(int i = 0;i < len - 1;i++){
             for(int j = i + 1;j < len;j++){
                 int n = (s[i] - '0') * 10 + s[j] -'0';
                 int m = (s[j] - '0') * 10 + s[i] - '0';
                 if((n > 10 && is_target(n)) || (m > 10) && is_target(m)) return true;
             }
         }
         return false;
    }

    static private boolean check_num1(int num) {

       int[] cnt = new int[10];
       int n = 0;
       while(num != 0){
           cnt[n++] = num % 10;
           num /= 10;
       }
        for(int i = 0;i < n;i++){
            for(int j = 0;j < n;j++){
                if(i != j && cnt[i] != 0 && is_target(cnt[i] * 10 + cnt[j]))
                    return true;
            }
        }
        return false;
    }

    static private boolean is_target(int num){
        if(num % 2 == 0) return false;
        for(int i = 2;i <= Math.sqrt(num);i++){
            if(num % i == 0) return false;
        }
        return true;
    }


    /**
     * c g 比例最多的子串
     * @param args
     */
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        char[] s = in.nextLine().toCharArray();
        int n = in.nextInt();

        int len = s.length;
        int cnt = 0,ret = 0;
        int l = 0;
        for(int left = 0,right = 0;right < len;right++)
        {
            //1.进入窗口
            if(s[right] == 'C' || s[right] == 'G')
                cnt++;

            //2.出窗口
            if(right - left + 1 > n)
            {
                if(s[left] == 'C' || s[left] == 'G') cnt--;
                left++;
            }

            //3.更新
            if(ret < cnt)
            {
                ret = cnt;
                l = left;
            }
        }

        for(int i = l;i < l + n;i++){
            System.out.print(s[i]);
        }
    }
}